﻿<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">意见反馈列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">意见反馈管理</a>
                </li>
                <li class="breadcrumb-item active">意见反馈列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <h4 class="example-title">意见反馈信息</h4>
                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">员工名称</label>
                            <select class="form-control" id="ipt_YuanGongMingCheng">
                            </select>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">状态</label>
                            <select class="form-control" id="slt_ZhuangTai">
                                <option value=''>请选择</option>
                                <option value='已解决'>已解决</option>
                                <option value='未解决'>未解决</option>
                            </select>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">时间</label>
                            <input type="text" class="form-control empty" autocomplete="off" data-date-format="yyyy-mm-dd" name="" id="ipt_ShiJian" data-plugin="datepicker" data-language="zh-CN" placeholder="请输入成立时间" />
                        </div>
                        <div class="form-group col-sm-3 row" style="padding-top:28px">
                            <div class="col-sm-6"><button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 100%; float: left;" onclick="bang('查')"><i class="icon wb-search"></i>查询</button></div>
                            <div class="col-sm-6"><button type="button" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 100%;" onclick="ChongZhi();">重置</button></div>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>人员</th>
                                <th>反馈内容</th>
                                <th>应答内容</th>
                                <th>状态</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th>人员</th>
                                <th>反馈内容</th>
                                <th>应答内容</th>
                                <th>状态</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                        </tfoot>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade example-modal-lg" id="exampleFormModal" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 90%">
        <div class="modal-content" style="width: 100%; height: 90%">
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu" onclick="" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="exampleFormModalLabel">查看内容</h4>
            </div>
            <div class="row">
                <div class="form-group col-sm-12"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10"></div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">反馈内容</label>
                    <textarea rows="10" class="form-control" style="width:100%" id="tt_FanKuiNeiRong" readonly="readonly"></textarea>
                </div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">应答内容</label>
                    <textarea rows="10" class="form-control" style="width:100%" id="tt_YingDaNeiRong" @*readonly="readonly"*@></textarea>
                </div>
                <div class="form-group col-sm-1"></div>

                <div class="form-group col-sm-2"></div>
                <div class="form-group col-sm-4">
                    <button type="button" id="bt_queding" class="btn btn-block btn-success" style="width: 100%;" onclick="xiugai()">确定</button>
                </div>
                <div class="form-group col-sm-4">
                    <button type="button" data-dismiss="modal" id="bt_ChongZhiE" class="btn btn-outline btn-success" style="width: 100%;" onclick="">取消</button>
                </div>
                <div class="form-group col-sm-2"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SpanXiTong").click();
        BangDingRenYuan();
        //列表显示
        bang("不查");
    })
    //绑定公司列表
    function bang(panduan) {
        //是不是点击的查询按钮
        if (panduan == "查") {
            ipt_YuanGongMingCheng = $("#ipt_YuanGongMingCheng").find("option:selected").val();
            slt_ZhuangTai = $("#slt_ZhuangTai").find("option:selected").val();
            ipt_ShiJian = $("#ipt_ShiJian").val();
        } else if (panduan == "不查") {
            ipt_YuanGongMingCheng = 0;
            slt_ZhuangTai = "";
            ipt_ShiJian = "";
        }
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[0, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                console.log(data);
                var param = {};
                param.sw = "";
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;

                param.ipt_YuanGongMingCheng = ipt_YuanGongMingCheng;
                param.slt_ZhuangTai = slt_ZhuangTai;
                param.ipt_ShiJian = ipt_ShiJian;

                console.log(param);

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../YiJianFanKui/GetListWithFenYe",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "t_RenYuanBiao.XingMing" },
                { "data": "FanKuiNeiRong", render: function (data, type, row) { if (row.FanKuiNeiRong.length <= 10) { return row.FanKuiNeiRong } else { return row.FanKuiNeiRong.substring(0, 10) + "..." } } },
                { "data": "YingDaNeiRong", render: function (data, type, row) { if (row.YingDaNeiRong.length <= 10) { return row.YingDaNeiRong } else { return row.YingDaNeiRong.substring(0, 10) + "..." } } },
                { "data": "ZhuangTai" },
                { "data": "ShiJian" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    if (row.ZhuangTai == "已解决") {
                        return '<button type="button" id="'+ row.Id +'" class="btn btn-outline btn-default" onclick="zhuangtai(' + row.Id + ')">未解决</button>' +
                            '<a title = "" data-target="#exampleFormModal" class="btn btn-outline btn-default" data-toggle="modal" id="btn_Xz" onclick="tanceng(' + row.Id + ')"><i class="icon wb-search" aria-hidden="true"></i>查看内容</a>';
                    } else {
                        return '<button type="button" id="'+ row.Id +'" class="btn btn-outline btn-default" onclick="zhuangtai(' + row.Id + ')">已解决</button>' +
                            '<a title = "" data-target="#exampleFormModal" class="btn btn-outline btn-default" data-toggle="modal" id="btn_Xz" onclick="tanceng(' + row.Id + ')"><i class="icon wb-search" aria-hidden="true"></i>查看内容</a>';
                    }
                }
            }]
        })
    }
    //人员绑定
    function BangDingRenYuan() {
        $.ajax({
            type: 'POST',
            url: '../KeHuZiYuanChi/BangDingRenYuan',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#ipt_YuanGongMingCheng");
                ddl.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].XingMing).val(date[key].Id);
                    ddl.append(opt);
                })
            },
        })
    }
    //文本重置
    function ChongZhi() {
        $("#ipt_YuanGongMingCheng").val(0);
        $("#slt_FaRen").val('');
        $("#ipt_ShiJian").val('');

        bang("不查");
    }
    //绑
    function tanceng(Id) {
        $.ajax({
            type: 'POST',
            url: '../YiJianFanKui/GetById',
            async: false,
            dataType: 'json',
            data: { id: Id },
            success: function (response) {
                console.log(response);
                $(response).each(function (key) {
                    $("#bt_queding").val(Id);
                    $("#tt_FanKuiNeiRong").val(response[key].FanKuiNeiRong);
                    $("#tt_YingDaNeiRong").val(response[key].YingDaNeiRong);
                })
            },
        })
    }
    //修改
    function xiugai() {
        $.ajax({
            type: 'POST',
            url: '../YiJianFanKui/Update',
            async: false,
            dataType: 'json',
            data: { id: $("#bt_queding").val(), yingda: $("#tt_YingDaNeiRong").val() },
            success: function (response) {
                if (response != -1) {
                    alert('应答完成');
                    bang('不查');
                } else {
                    alert('应答完成失败，请确认填写信息无误后及时联系管理员！谢谢~');
                }
            },
        })
    }
    //状态
    function zhuangtai(Id)
    {
        $.ajax({
            type: 'POST',
            url: '../YiJianFanKui/Update',
            async: false,
            dataType: 'json',
            data: { id: Id, zhuangtai: $("#" + Id + "").text(),er:"2" },
            success: function (response) {
                if (response != -1) {
                    alert('应答完成');
                    bang('不查');
                } else {
                    alert('应答完成失败，请确认填写信息无误后及时联系管理员！谢谢~');
                }
            },
        })
    }
</script>